﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TaskCompletionSourceUser;
using WebService;

namespace TestTCS
{
	class AsyncWebClient
	{
		static void Main(string[] args)
		{
			var proxy = new JSONServiceProxy("http://localhost:57142/");

			Console.WriteLine("Call to get the orders");
			var WebGetTask = proxy.GetObject<List<Order>>("api/Order");

			Console.WriteLine("Doing other Tasks while we wait");
			
			Console.WriteLine("Orders Returned: " + WebGetTask.Result.Count());

			Parallel.ForEach(WebGetTask.Result, 
				o => Console.WriteLine("Order ID: " + o.Id + " Person: " + o.Person.Name));
			
			Console.ReadLine();
		}
	}
}
